using Microsoft.Xna.Framework;
//using CoreLibrary;


namespace TroTro
{
    /// <summary>
    /// This is a game component that implements sprite
    /// </summary>
    public class Vehicle : Sprite
    {
        #region Fields

        protected Game _game;

        protected float Health;
        private int _rightTireHealth = 500;
        private int _leftTireHealth = 500;
        private int _rightBackTireHealth = 250;
        private int _leftBackTireHealth = 250;
        protected float Speed = 5.0F;
        protected float TurnSpeed = 0.07F;
        public Vector2 Screenbounds;

        #endregion

        #region Properties

        public int RightTireHealth
        {
            get { return _rightTireHealth; }
            set
            {
                _rightTireHealth = value;
            }
        }

        public int LeftTireHealth
        {
            get { return _leftTireHealth; }
            set
            {
                _leftTireHealth = value;
            }
        }

        public int RightBackTireHealth
        {
            get { return _rightBackTireHealth; }
            set { _rightBackTireHealth = value; }
        }

        public int LeftBackTireHealth
        {
            get { return _leftBackTireHealth; }
            set { _leftBackTireHealth = value; }
        }

        #endregion

        #region XNA Methods

        public Vehicle(Game game)
            : base(game)
        {
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            if((Position.Y + (Texture.Height / 2)) > Screenbounds.Y)
            {
                Position.Y -= 5;
            }
            else if (Position.Y - (Texture.Height / 2) < 0)
            {
                Position.Y += 5;
            }
            else if (Position.X < 0)
            {
                Position.X += 5;
            }
            else if (Position.X > Screenbounds.X)
            {
                Position.X -= 5;
            }

            RightTireHealth = (int)MathHelper.Clamp(RightTireHealth, 0, 500);
            LeftTireHealth = (int)MathHelper.Clamp(LeftTireHealth, 0, 500);
            RightBackTireHealth = (int) MathHelper.Clamp(RightBackTireHealth, 0, 250);
            LeftBackTireHealth = (int) MathHelper.Clamp(LeftBackTireHealth, 0, 250);

            base.Update(gameTime);
        }

        #endregion
    }
}
